import fetch from "../axios";

const queryDeviceService = (param) => {
  return fetch.post("/api/v1/device/query", {
    online_state: param.onlineState,
    push_state: param.pushState,
    device_add_date_start: !param.dateRange?null:param.dateRange[0]?param.dateRange[0].format('yyyy-MM-DD'):null,
    device_add_date_end: !param.dateRange?null:param.dateRange[1]?param.dateRange[1].format('yyyy-MM-DD'):null,
    pageable: {
      page: 1,
      page_count: 10,
    },
  })
}

const saveDeviceService = (record) => {
  return fetch.post("/api/v1/device/save", {
    ...record
  });
}

const deleteDeviceService = (id) => {
  return fetch.delete(`/api/v1/device/delete/${id}`);
}

export {
  queryDeviceService,
  saveDeviceService,
  deleteDeviceService
}